<?php
namespace tp5_lib\account\logic;

use tp5_lib\install\logic\Module;

class AccountModule extends Module
{
    public function update()
    {
        $template=require __DIR__ . "/../" . config("module.config_dir") . "account.template.php";
        $result=[
            "trade"=>[],//交易类型列表
            "payment"=>[],//支付方式列表
        ];
        $this->scan("account",function($module,$config)use(&$result,$template){
            if(!empty($config["trade"])){
                foreach($config["trade"] as $id => $item){
                    $item = array_merge($template["trade"]["template"],$item);
                    $item["module"]=$module;
                    $result["trade"][$id] = $item;
                }
            }
            if(!empty($config["payment"])){
                foreach($config["payment"] as $id => $item){
                    $item = array_merge($template["payment"]["template"],$item);
                    $item["module"]=$module;
                    $result["payment"][$id] = $item;
                }
            }
        });
        $this->write("account",$result);
        return true;
    }
}
